package com.springsecurity.demo.controller;

import com.springsecurity.demo.vo.Student;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @author : yj
 * @className : HellorController
 * @creat : 2020-08-13 21:17
 * @desc : TODO
 */

@RestController
@RequestMapping("/api/")
public class HelloController {

    private static final List<Student> STUDENT = Arrays.asList(
            new Student(1, "Jack"),
            new Student(2, "Tom")
    );

    @GetMapping(path = "student/{id}")
    public Student toHello(@PathVariable Integer id) {
        return STUDENT.stream().filter((e) -> id.equals(e.getId()))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("用户不存在"));
    }

}
